package com.kuaixueit.crm.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;
import com.kuaixueit.crm.pojo.QueryVO;
import com.kuaixueit.crm.service.StaffService;

/**
 * 职位的相关操作
 * @author Administrator
 *
 */
@Controller
@RequestMapping("staff")
public class StaffController {
	
	
	@Autowired
	private StaffService staffService;

	/**
	 * 
	 * @param page
	 * @param rows
	 * @return
	 */
	@RequestMapping("list")
	@ResponseBody //返回值hashmap对象转化为json数据
	public Map getListByDeptName(
			QueryVO query,
			//@RequestParam(defaultValue="1")如果不传递参数默认是1
			@RequestParam(defaultValue="1")Integer page,
			@RequestParam(defaultValue="3")Integer rows){
		Map map = new HashMap();
		try {
			//分页查询
			PageInfo info = staffService.findPage(query, page, rows);
			//符合条件的总数
			map.put("total", info.getTotal());
			//当前页的数据
			map.put("rows", info.getList());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return map;
	}
}
